package com.wc.alorithm_blue_bridge._思维.Q3263;

import java.util.*;

/**
 * @Author congege
 * @Description
 * @Date Created in 2023/11/27-15:38
 */
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int l = scan.nextInt();
        int r = scan.nextInt();
        int x = scan.nextInt();

        ArrayList<Exam> exams = new ArrayList<>();
        Exam examTmp = new Exam(Integer.MAX_VALUE, 0, 0, new HashSet<Integer>());
        exams.add(examTmp);

        int[] scores = new int[n];

        for (int i = 0; i < n; i++) {
            scores[i] = scan.nextInt();
            ArrayList<Exam> tmp = new ArrayList<>();
            for (Exam exam : exams) {
                tmp.add(exam);
                int minScore = Math.min(exam.minScore, scores[i]);
                int maxScore = Math.max(exam.maxScore, scores[i]);

                int sumScore = exam.sumScore + scores[i];
                if (sumScore <= r) {
                    HashSet<Integer> set = new HashSet<>(exam.set);
                    set.add(scores[i]);
                    tmp.add(new Exam(minScore, maxScore, sumScore, set));
                }
            }
            exams = tmp;
        }
        int ans = 0;
        for (Exam exam : exams) {
            int minScore = exam.minScore;
            int maxScore = exam.maxScore;
            int sumScore = exam.sumScore;
            // 所需要满足的条件
            if (sumScore >= l && maxScore - minScore >= x && exam.set.size() >= 3) {
                ans++;
            }
        }

        System.out.println(ans);
        scan.close();
    }

    static class Exam {
        // 试卷最小成绩
        int minScore;
        // 试卷最大成绩
        int maxScore;
        // 试卷总成绩
        int sumScore;
        // 试卷内容，不重复值
        HashSet<Integer> set;

        public Exam(int minScore, int maxScore, int sumScore, HashSet<Integer> set) {
            this.minScore = minScore;
            this.maxScore = maxScore;
            this.sumScore = sumScore;
            this.set = set;
        }
    }
}
